// eslint-disable-next-line import/no-extraneous-dependencies
import axios from 'axios';

import { useGlobalStore } from '../store';

const request = axios.create({
  baseURL: process.env.VUE_APP_BASE_URL,
});

// 添加请求拦截器
request.interceptors.request.use((config) => {
  const cfg = config;
  const GlobalStore = useGlobalStore();
  cfg.headers.authorization = GlobalStore.authorization;
  return cfg;
}, (error) => Promise.reject(error));

export default request;
